Email Conversation : Grab Email textBody Attribute

Hello,

Looking for some guidance from the Dev Team on how we can pull email textBody attribute from an email conversation. Here is the scenario. We have Customer ID included in the email body and we would like to grab the Customer ID number to run it against an existing API that returns profile information.

Is there a way that I can grab the customer ID within the textBody of the email in architect inbound email flow? I pulled the conversationId & messageId using the below API. I have an idea on how to set it up using a data action but I am not sure if this is the correct approach.

Email API: api/v2/conversations/emails/{input.conversationId}/messages/{input.messageId}

Here an example of the conversation we get today in the interactions view.
{
"id": "emailID here",
"to": [
{
"email": "emailaddress@example.com",
"name": "emailaddressname"
}
],
"cc": [],
"bcc": [],
"from": {
"email": "emailaddress@example.com"",
"name": "emailaddress@example.com""
},
"attachments": [],
"textBody": "\r\n View in browser https:URLHERE\r\n[HEADERIMAGE]\r\nSubject Line:\r\n\r\nCustomer Email Address: emailaddress@example.com\r\n\r\nCustomer Name:\r\n\r\n(comments)\r\n\r\n Customer ID: 12345 \r\n\r\n\r\n", etc.......}

Update** I am also open to suggestions in case there is an easier way to accomplish this using the Email Builder.

Thank you.

See the section Example: Scan for a case ID in the email body here: https://help.mypurecloud.com/articles/navigate-email-flow/. This shows using a boolean function to find a string in the body. For your case where you want to actually fetch a value, it's going to be a bit more complicated. You can use the FindString function to find a marker in the body to locate where a value should follow. For your example above, that might be looking for Customer ID: and then using substring to grab the following 5 characters. You'll have to work out the exact logic based on your formatting and how you validate an ID, but that should be the gist of how you can do that.

If your case is more complicated than this approach will allow for, I'd strongly suggest using a 3rd party service (of your own design or a paid service) to send it the email body, parse it, and return the values you're looking for.

@Tim, I will review the article and see where that gets me. I really appreciate the information. Have an awesome rest of your week! :slightly_smiling_face:

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