#Shopify Update Order is missing input options due to a lack of recognizing GraphQL

1 messages · Page 1 of 1 (latest)

paper ridge
#

Hey!

I see that you can only update the phone number of an order, but I think Composio has it wrong, I think because it's used to RESTapi's and not GraphQL, so perhaps the schema you have there is wrong. Can I extend this manually somehow or can you guys? 🙏

lethal swanBOT
#

Yes, updating the actions to use the GraphQL APIs is in the pipeline. I’m checking with the team about extending it manually and will get back to you soon!

lethal swanBOT
#

Hi Daniel! We support creating custom tools, where in you can define your own logic & just need to specify the tool-name & the auth would be injected, learn more here: https://docs.composio.dev/tool-calling/custom-tools

Here's the snippet for creating Custom action for Shopify. It gets the Shop details (GraphQL APIs):

import typing as t
from composio_openai import ComposioToolSet, action
from openai import OpenAI

client = OpenAI(
    api_key="<openai-api-key>"
)
toolset = ComposioToolSet(api_key="<composio-api-key")


@action(toolname="shopify")
def get_shop_details_custom(
    execute_request: t.Callable,
) -> dict:
    """
    Gets the details of a shop in shopify

    :return shop: Return shop detail
    """
    query = """
    {
        shop {
            name
            email
        primaryDomain {
            url
            host
        }
        currencyCode
        }
    }
    """

    response = execute_request(
        endpoint="https://<shopify-sub-domain>.myshopify.com/admin/api/2023-04/graphql.json",
        method="POST",
        body={"query": query},
        # parameters=None,
    )
    return response

tools = toolset.get_tools(actions=[get_shop_details_custom])
question = "Get details about my Shopify Shop"
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": question}],
    tools=tools,
    tool_choice="auto",
)
result = toolset.handle_tool_calls(response=response)
print(result)

Lmk if you need any assistance!

paper ridge
#

Thanks for the info! Can anyone from the devs explain how I can pass in authentication params from what's stored in Composio's connectedAccounts into a custom tool action? Say I want to extend manually what you currently support in Shopify (just like in my case, I want to support canceling an order or updating an order with more params but keeping the existing account).

paper ridge
#
 authCredentials: {
    headers: {
      Authorization: 'Bearer ya29.*****hfjQ0177',
      'x-request-id': '2807******4c'
    },
    queryParams: {},
    baseUrl: 'https://www.googleapis.com'
  }
paper ridge
idle kestrel
#

@paper ridge Taking a look at it

idle kestrel
#

Hey @paper ridge, thanks for bringing this to our attention—There's a bug on our end preventing automatic auth injection.
Until we fix this, please use the snippet below (this is an example for getting shop details, you can make changes acc to your usecase).

import { LangchainToolSet } from "composio-core"

const toolset = new LangchainToolSet({ apiKey: "{{composio-api-key}}" }) //add you composio-api-key here
await toolset.createAction({
    actionName: 'get_shop_details_custom',
    toolName: 'shopify',
    description: 'Get the details of a shop in Shopify',
    callback: async (inputParamsZod, authCredentials, executeRequest) => {
        const mutation = `
                {
                shop {
                    name
                    email
                primaryDomain {
                    url
                    host
                }
                currencyCode
                }
            }
            `;

        try {
            const responseData = await executeRequest({
                endpoint: 'https://{{shopify-subdomain}}.myshopify.com/admin/api/2023-04/graphql.json', //add your shopif subdomain here
                method: 'POST',
                parameters: [{ name: 'Content-Type', value: 'application/json', in: 'header' },
                {
                    name: 'X-Shopify-Access-Token',
                    value: "{{your-access-token}}", //add your access token here
                    in: 'header',
                },],
                body: { query: mutation },
            });
            return {
                data: responseData,
                successful: true
            };
        } catch (e) {
            console.log(e);
            return {
                data: {},
                successful: false
            };
        }
    },
})
const res = await toolset.executeAction({ action: "get_shop_details_custom" })
console.log("res :: ", JSON.stringify(res));

I'll update you once the issue is resolved!

paper ridge
#

@idle kestrel thanks! The issue with this is that I have multiple "entities" / customers, it will fix it only for that customer but not all.

lethal swanBOT
#

Yes, that's understandable. Our team is working on fixing this. I'll notify you once it's live!

paper ridge
#

Is there a board to see the progress on this? how much of a priority is it / when expected to be solved?

idle kestrel
#

We don’t have a progress board ATM—this is a high priority and you can expect this to he fixed within 48hrs.

idle kestrel
#

Hey @paper ridge , the issue has been fixed—Please use [email protected]

I've attached the code snippet for ref—Note that I've added the extractSubdomain() to extract the subdomain of user's Shopify Acc and dynamically passing it in the endpoint arg, this is because our Shopify tool uses Shopify's REST APIs & the endpoint is different for GraphQL.

LMK if you need any help—happy to assist!

paper ridge
#

what about authentication data (token etc)?

lethal swanBOT
#

Auth would be injected automatically!