Receiving empty emails when I try to generate them through API

Hello everyone! I hope they are well.

I am trying to generate email interactions from the JavaScript SDK, the problem is that the interaction comes empty, that is, it does not show either body or subject to the agent that takes the interaction as shown in the image below

I tried several things but I didn't find anything that helped me, I'll share the code with you, maybe you'll find something that I didn't.

const authenticate = () => {
    return client.loginClientCredentialsGrant(clientId, clientSecret)
        .then(() => {
            console.log('Authentication successful');
        })
        .catch(err => {
            console.error('Authentication error', err);
            throw err;
        });
};

const sendEmail = (subject, htmlBody) => {
    const conversationsApi = new platformClient.ConversationsApi();

    const body = {
        queueId: queueId,
        toAddress: toAddress,
        fromAddress: fromAddress,
        provider: provider,
        subject: subject,
        htmlBody: htmlBody,
        direction: direction
    };

    return conversationsApi.postConversationsEmails(body)
        .then(data => {
            console.log(`Email sent successfully: ${JSON.stringify(data, null, 2)}`);
        })
        .catch(err => {
            console.error('Error sending email', err);
            throw err;
        });
};

// Usage example
authenticate()
    .then(() => {
        const subject = 'New form submitted';
        const htmlBody = 'Name: John Doe\nEmail: john.doe@example.com\nMessage: This is a test message.';
        return sendEmail(subject, htmlBody);
    })
    .catch(err => {
        console.error('Error', err);
    });```

Thank you all!

If you want to create an email conversation, you need to integrate with a mail provider of your choosing to send an email to an inbox that's monitored by Genesys Cloud. You can find information about configuring ACD email in your org here: About ACD emails - Genesys Cloud Resource Center.

If you're trying to route third party objects for an integration, that looks as expected. The typical approach is to use a Script to embed whatever the media is for the conversation. See here for more information about third party object routing: https://developer.genesys.cloud/commdigital/third-party-object-routing/.

1 Like

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