How to send an email from script

Hello,

My client needs to be able to send an OUTBOUND email from a script by clicking on en 'Send email' button that we want to configure. I have tried doing this through a POST request to api/v2/conversations/emails, but I have read in this forum that I am unable to call this endpoint using Client Credentials and that a user context is needed. The email needs to contain dynamic data generated in the script e.g. the hour and address of an appointment. I thought of doing this by using an endpoint in the Conversations API, but I don´t know whether I am using the wrong endpoint or whether it is just not possible to call the API from an external web service and trigger the sending of the email in question. Could you advise as to whether what I am trying to achieve is possible or whether I am using the wrong endpoint?

I have also tried doing this using a Data Action but I encounter the same issue, I am unable to call api/v2/conversations/emails using Client Credentials. I'm not sure what the workaround is, if every time I need to send an email I need a user context.

P.S.: It would also be acceptable that this button on the script retrieved all the dynamically generated data upon click and placed it on a 'new email' in the 'Interations' section, the email only awaiting the AGENT to press send.

1 Like

Hi SabioDev,

Thanks for the question. I found this page in some previous forum posts related to outbound email that you may find useful. Also, check out this api endpoint for sending emails. Hope it helps!

Thanks

Hello,

Unfortunately, it is currently not possible to send an email from a Script (via a Genesys Cloud Data Action).
As you mentioned in your post, creating/sending a Genesys Cloud E-Mail requires a user context (access token obtained via Implicit Grant, Authorization Code Grant, SAML2 Bearer Grant) when invoking the corresponding Platform API endpoint.
Genesys Cloud Data Actions integration relies on an OAuth Client Credentials Grant client to authenticate and get authorized (configuration at the Genesys Cloud Data Actions integration level) - "server" context.
Which means that a request to create an email out will be rejected when invoked via a Genesys Cloud Data Action (from an Architect flow, from a Script, ...).

The Third Party Email and Chat Routing article is not about Genesys Cloud emails.
The request can indeed be used with an access/authorization token obtained via Client Credentials Grant.
But in this case, it can only create a 3rd party email - submitted to Genesys Cloud for distribution, to a Contact Center Agent, as a task/work-item of mediaType email.
It will comply with Agent utilization settings for email (in Genesys Cloud). But it is not a "real" email (no email will be sent out to a Mail Server/email address).

In future:

There is a Genesys Cloud idea on Agentless Email.
The idea is to allow sending an email out (a real email this time) using a Client Credentials Grant token - like the Agentless SMS.
The idea appears to have been accepted. But I don't have a timeline to communicate when it will be implemented and made available.

There is another idea you can vote for (in Community review) to allow Genesys Cloud Data Actions to manipulate conversations.

Now:

Currently, the only way would be for you to develop a custom web app, that leverages Platform API, and that is embedded in the Genesys Desktop.
You can run/host a web page/web app inside Genesys Cloud Desktop with Client Application integrations.
In your use case, an appropriate one could be the interaction widget integration as it will be made available as a custom tab in the conversation, and as you can pass the corresponding conversationId to your web app via URL interpolation with pcConversationId.
The code in your web app can trigger a user context based authorization flow (e.g. Token Implicit Grant). The web app running inside Genesys Desktop, this authorization process/flow will be transparent to the user (he won't have to enter his username/credentials on a login page for this).
From there, you can invoke Platform API requests on behalf of the user - which means that the request to create an email out (a real one) will be accepted. You can also retrieve the identity (username/email/displayName) of the logged-in user.

You can have a look at this Chat Assistant blueprint. It does not cover email but shows how to leverage an interaction widget exposing a web app (that leverages Platform API - using a Token Implicit Grant authorization flow).

As a note, you could possibly also expose a web app inside the Script itself (via a web component).
But depending on what identity provider is used for authentication (Genesys Cloud, Salesforce, Okta, ...), there might be cases where the user would not be automatically signed in.
I don't know for sure - but not having all these IdP available in a test environment, I haven't tried/tested the behavior for authorization flow in these different scenari and if the user is prompted to login or not.

Regards,

Thank you Jerome. Instead of using Genesys API or tools, is it possible to use a third party email service provider and post that email at the end of a genesys email conversation once sent, as proof that the email was indeed sent out? In retrospective and for verification purposes, my client might want to be able to see what details were sent out on these 'appointment confirmation emails', even if the email service provider is not Genesys.

Hello,

I don't think such is possible.
If you are not using Genesys Cloud email service, there is a custom SMTP server integration.
I can't say if you would be able to add something at the end of an email conversation (it doesn't sound easy for a 3rd party to make the link between 2 set of emails). And this info would not appear in the email history on Genesys Cloud side.

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.