Email

The agent SDK will support multiple email providers for incoming and outgoing email in the future. Today, there is only support for Mailgun by Sinch. Mailgun has a free version for you to try.

Within more organizations, email is the most common and natural way to communicate. Your agents should be able to work there too!

Getting things setup

Before you go any further, you'll need to get a Mailgun account. If you only want to send emails, the Free or Basic plan will work just fine. If you also want to process incoming email then you'll need at least the Foundation version due to the message retention requirements.

Once you have signed up - you'll want to go through the guide to get everything configured. For testing purposes, one of their sandbox domains will likely work fine. You can find those here or set up your own at: https://app.mailgun.com/mg/sending/domains

For production environments, be sure to setup the domain entirely - including DMARC and SPF so that your email does not wind up in spam. It is recommended not to send email from your primary corporate domain.

Setting up incoming webhooks

So far we've only covered outgoing email. To configure incoming email, you need to configure a route - done here: https://app.mailgun.com/mg/receiving/routes

First, select Custom and then enter an expression like the following:

match_recipient("^nova\+(.*)@teamagents.io$")

The part before the first + is the general name of your agent team and the domain after the @ is the domain that you have setup above. Then, scroll down to Store and Notify and enter the following url:

https://<host>.<region>.api.peoplelogic.dev/api/v1/agents/common/incoming-email

Where host and region were assigned to you during signup. Give the route a name and click Save and you're done!

Configuring your agent

You will need two keys and some basic properties to activate the email functionality. Only the first is required and is located under the Sending Keys area of the settings for the domain you want to send from. The second is generic to your account and is located here: https://app.mailgun.com/settings/api_security

application.properties
mailgun.api.key=${MAILGUN_API_KEY:}
mailgun.webhook.key=${MAILGUN_WEBHOOK_KEY:}

peoplelogic.agent.email.from=${AGENT_EMAIL_ADDRESS:[email protected]}
peoplelogic.agent.email.name=Shruti
peoplelogic.agent.email.company=(Nova)
peoplelogic.agent.team.name=Nova

You can adjust the properties above to personalize them to your agents.

Watching it work

Now, whenever anyone sends an email to sample+<workspacelias>@teamagents.io it will get picked up by the agents as long as the user is a valid user in your workspace. The agents will reply back to that user with the answer or ask for more information.

A new tool will also be unlocked for your agents to use, sendEmail . Now you can assign tasks to your agents that also include instructions to send an email to someone. For example, we could send a summary of the conversation or as part of a scheduled task have the HR Coordinator check for workiversaries and send the user a nice email.

Last updated

Was this helpful?