Analyzing an email with ChatGPT and saving the analysis as CAD
In this example, we'll use ChatGPT to analyze an email message, suggest a draft reply, and save the result so the agent can see it in Communication Panel.
When using the examples that connect to third-party AI services or any other third-party service, please be aware that these services are not operated by Sinch, and we do not guarantee their availability or performance. Data processed through these services is handled outside of the Sinch Contact Pro environment, so it is important to review their privacy policies and data retention practices, and to ensure your use complies with applicable laws and regulations, including GDPR. Sinch support is limited to the integration process within the Sinch Contact Pro product. Any service-specific issues should be directed to the third-party support team.
For this integration, you'll need to configure the following:
-
Endpoint URL: https://api.openai.com/v1/chat/completions
-
Conversation Direction: Inbound
-
Queues: Email queue
You need to configure Extra Data Included When E-Mail Allocated for either the email channel ( ) or the email queue ( ).
- Authentications:
- Authentication ID: api-key
- Secret: API key of the OpenAI platform
- JSON for Configuration
This example uses an authentication header and the POST method for prompting ChatGPT to analyze a customer email and write a draft reply. It works on the email channel. The response saves the returned data, specified in the request. This data will then be visible as conversation attached data (CAD) to the agent in Communication Panel's Conversation Details extension. To show the data in its own AI analysis block in Conversation Details, see Using Extra Data in the System Configurator document.
{ "request": { "method": "POST", "headers": { "authorization": "Bearer {authentications.api-key}" }, "body": { "model": "gpt-4o", "messages": [ { "role": "user", "content": "Analyze the following email and provide the results in a JSON object with the following keys: Email language, Sentiment, Context, Summary, and Draft reply. The JSON object values should be in the original language of the email.\n\nSubject: {contact.email.subject}\n\nEmail: {contact.email.body}\n\nProvide the JSON object with these keys:\n\n{\n \"Email language\": \"Detected language of the email.\",\n \"Sentiment\": \"Customer sentiment in the email.\",\n \"Context\": \"Context of the email in one word (Spam, Marketing, Service, etc).\",\n \"Summary\": \"Compact summary of the email.\",\n \"Draft reply\": \"Compact draft reply\"\n}" } ], "max_tokens": 1024, "response_format": { "type": "json_object" } } }, "response": { "save": { "AI-analysis": "{response.body.choices[-1].message.content}" } } }